﻿define(function (require, exports, module) {
    var PDFTextObject = require('./Reader_TextObject.js');
    var PDFRect = WebPDF.PDFRect;
    var RectUtils = WebPDF.RectUtils;

    /**
     * 文本范围对象
     * @param {Number} startIndex 起始索引
     * @param {Number} endIndex 结束索引
     * @private
     * @constructor
     */
    var TextBoundInfo = function (startIndex, endIndex) {
        this.startIndex = startIndex;
        this.endIndex = endIndex;
    };

    WebPDF.PDFData.Text.TextBoundInfo = TextBoundInfo;
    var CharInfo = WebPDF.PDFData.Text.CharInfo;

    /**
     * @private
     * @constructor
     */
    WebPDF.PDFData.Text.PDFTextPage = function () {
        /**
         * Text object list
         * @type {Array.<WebPDF.PDFData.Text.PDFTextObject>}
         */
        this.textObjectList = [];
        /**
         * 页面中所有文本内容的长度
         * @type {number}
         */
        this.strSize = 0;
        /**
         * 当前页面索引
         * @type {number}
         */
        this.pageIndex = -1;
        /**
         * 页面文本总行数
         * @type {number}
         */
        this.lineCount = 0;
        var _self = this;

        /**
         * 获取行数
         * @returns {number} 行数
         * @private
         */
        function _getLineCount() {
            var objSize = _self.textObjectList.length;
            if (objSize === 0) {
                return 0;
            }
            return _self.textObjectList[objSize - 1].lineIndex + 1;
        }

        /**
         * 根据json数据进行初始化
         * @param jsonData 页面文本的JSON数据
         * @returns {boolean} 初始化成功返回true，否则返回false
         */
        this.init = function (jsonData) {
            try {
                if (!jsonData) {
                    return false;
                }
                if (jsonData.pagenum != null) {
                    this.pageIndex = parseInt(jsonData.pagenum);
                }
                else {
                    console.warn("Page index of text data is null.");
                    return false;
                }
                if (jsonData.texts != null) {
                    var textObjArr = jsonData.texts;
                    for (var i = 0; i < textObjArr.length; i++) {
                        var textObj = textObjArr[i];
                        if (textObj.li == null || textObj.ci == null || textObj.oi == null || textObj.cs == null) {
                            console.warn("Parse text object data failed.");
                            return false;
                        }
                        var fxTxtObj = new PDFTextObject();
                        fxTxtObj.lineIndex = parseInt(textObj.li);
                        fxTxtObj.objIndex = parseInt(textObj.oi);
                        fxTxtObj.charIndex = parseInt(textObj.ci);
                        var charsArr = textObj.cs;
                        for (var j = 0; j < charsArr.length; j++) {
                            var charObj = charsArr[j];
                            if (charObj.length != 5)
                                return false;
                            var charInfo = new CharInfo();
                            var left = parseFloat(charObj[0]),
                                  top = parseFloat(charObj[1]),
                                  width = parseFloat(charObj[2]),
                                  height = parseFloat(charObj[3]);
                            charInfo.charRect = new PDFRect(left, top, left + width, top + height);
                            RectUtils.normalize(charInfo.charRect);
                            charInfo.charCode = parseInt(charObj[4]);
                            fxTxtObj.charInfoArray.push(charInfo);
                        }
                        
                        fxTxtObj.textPageMatrix = new WebPDF.PDFMatrix();
                        if(typeof textObj.mt != 'undefined' && textObj.mt!=null)
						{
							var jsonMatrix = textObj.mt;
							fxTxtObj.textPageMatrix.Set(jsonMatrix[0],jsonMatrix[1],jsonMatrix[2],jsonMatrix[3],jsonMatrix[4],jsonMatrix[5]);
						}
						else //兼容1.0
						{
							fxTxtObj.textPageMatrix.Set(1,0,0,1,0,0);
						}
                        if(typeof textObj.wm != 'undefined' && textObj.wm!=null)
						{
							fxTxtObj.writingMode = textObj.wm;
						}
                        
                        fxTxtObj.init();
                        this.textObjectList.push(fxTxtObj);
                    }
                    var lastObj = this.textObjectList[this.textObjectList.length - 1];
                    if(lastObj){
                        this.strSize = lastObj.charIndex + lastObj.getStrSize() + 1;
                    }else{
                        this.strSize = 0;
                    }

                    this.lineCount = _getLineCount();
                }
                else {
                    console.warn("Parse text object data failed.");
                    return false;
                }
            }
            catch (ex) {
                console.error(ex);
                return false;
            }
            return true;
        };

        /**
         * 根据光标位置获取对应的 PDFPageObject 对象索引
         * @param {WebPDF.PDFPoint} pdfPoint 光标位置
         * @returns {number} 返回-1表示失败
         */
        this.getObjTextIndexByPoint = function (pdfPoint) {
            var size = this.textObjectList.length;
            for (var i = 0; i < size; i++) {
                var rect = this.textObjectList[i].getAllObjectPDFRect(false);
                if (RectUtils.ptInRect(rect,pdfPoint.x, pdfPoint.y)) {
                    return i;
                }
            }
            return -1;
        };

        /**
         * 根据光标位置获取指定的字符索引
         * @param {WebPDF.PDFPoint} pdfPoint 光标位置
         * @returns {number} 光标位置指定的字符索引
         */
        this.getCharIndexByPoint = function (pdfPoint) // getIndexByPoint => getCharIndexByPoint
        {
            var objIndex = this.getObjTextIndexByPoint(pdfPoint);
            if (objIndex == -1) {
                return -1;
            }
            var charCount = this.textObjectList[objIndex].getSize();
            var index = -1;
            for (var j = 0; j < charCount; j++) {
                var rect = this.textObjectList[objIndex].getObjectPDFRect(j, 1);
                if (RectUtils.ptInRect(rect,pdfPoint.x, pdfPoint.y)) {
                    index = j;
                    break;
                }
            }
            if (index == -1) {
                return -1;
            }
            return this.textObjectList[objIndex].objIndex + index;
        };

        /**
         * 判断给定的字符是否是ansi字符或者数字
         * @param ch 给定的字符
         * @returns {boolean} 如果是是ansi字符或者数字，返回true，否则返回false
         * @private
         */
        function _isAnsiWordOrDigital  (ch) {
            var regexp = /^[0-9a-zA-Z]*$/;
            return !(ch > 255 || (!regexp.test(ch) && ch != '.' && ch != '-'));
        }

        /**
         * 获取指定范围的字符所占的矩形区域
         * @param startCharIndex 起始字符索引
         * @param count 数量
         * @returns {Array.<WebPDF.PDFRect>} 指定范围的字符所占的矩形区域
         */
        this.getPDFRect = function (startCharIndex, count,matrixArray,writingModeArray) {
            var rectArray = [];
            var totalCharCount = this.getSize();
            if (startCharIndex < 0 || startCharIndex >= totalCharCount || count <= 0)
                return rectArray;
            if (startCharIndex + count > totalCharCount) {
                count = totalCharCount - startCharIndex;
            }
            var startObjIndex = -1;
            var objStartCharIndex = -1;
            var objCount = this.textObjectList.length;
            for (var i = 0; i < objCount; i++) {
                var textObj = this.textObjectList[i];
                var objLastCharIndex = textObj.objIndex + textObj.getSize() - 1;
                if (startCharIndex <= objLastCharIndex) {
                    startObjIndex = i;
                    objStartCharIndex = startCharIndex - textObj.objIndex;
                    if (objStartCharIndex < 0) {
                        objStartCharIndex = 0;
                        count--;
                    }
                    break;
                }
            }
            var nextObjIndex = startObjIndex;
            var nextObjStartCharIndex = objStartCharIndex;
            var numbers = 0;
            while (count > 0) {
                if (nextObjIndex >= objCount)
                    return 0;
                var nextTextObj = this.textObjectList[nextObjIndex];
                var objCharCount = nextTextObj.getSize();
                var leaveCharCount = objCharCount - nextObjStartCharIndex;
                var rect = nextTextObj.getObjectPDFRect(nextObjStartCharIndex, count);
                rectArray.push(rect);
                if(typeof matrixArray != "undefined" && matrixArray!=null)
					matrixArray.push(nextTextObj.textPageMatrix);
				if(typeof writingModeArray != "undefined" && writingModeArray!=null)
					writingModeArray.push(nextTextObj.writingMode);
                numbers ++;
                count = count - leaveCharCount;
                if (count > 0 && nextObjIndex < objCount - 1) {
                    var end_index = nextTextObj.objIndex + objCharCount - 1;
                    var next_start = this.textObjectList[nextObjIndex + 1].objIndex;
                    if (next_start - end_index != 1) //TextObj与TextObj空格【间隔】
                    {
                        count--;
                    }
                }
                nextObjIndex++;
                nextObjStartCharIndex = 0;
            }
            return rectArray; //numbers;
        };

        /**
         * 根据指定的字符索引获取 PDFTextObject 的索引
         * @param charIndex 字符索引
         * @returns {Number}  PDFTextObject 的索引, 失败情况下返回-1
         */
        this.getObjIndexByCharIndex = function (charIndex) //getIndexByCharIndex =》 getObjIndexByCharIndex
        {
            if (charIndex >= this.strSize){
                return -1;
            }
            var objCount = this.textObjectList.length;
            for (var i = 0; i < objCount; i++) {
                var textObj = this.textObjectList[i];
                if (charIndex <= textObj.charIndex + textObj.getStrSize() - 1) {
                    if (charIndex < textObj.charIndex) {
                        if (i > 0 && textObj.lineIndex != this.textObjectList[i - 1].lineIndex) {
                            return textObj.objIndex;
                        }
                        else {
                            return textObj.objIndex - 1;
                        }
                    }
                    var index = charIndex - textObj.charIndex;
                    return textObj.objIndex + textObj.getObjectIndex(index);
                }
            }
            return 0;
        };

        /**
         * 获取总的文本长度
         * @returns {number} 总的文本长度
         * @constructor
         * @private
         */
        this.getStrSize = function () {
            return this.strSize;
        };

        /**
         * 获取总的字符数
         * @returns {Number} 总的字符数
         * @private
         */
        this.getSize = function ()
        {
            var size = this.textObjectList.length;
            if (size == 0) {
                return 0;
            }
            else {
                return this.textObjectList[size - 1].objIndex + this.textObjectList[size - 1].getSize();
            }
        };

        /**
         * 获取页面的所有文本内容
         * @returns {String} 页面的所有文本内容
         * @constructor
         * @private
         */
        this.getPageAllText = function ()
        {
            var objSize = this.textObjectList.length;
            if (objSize == 0) {
                return "";
            }
            return this.getPageText(0, this.getSize());
        };

        /**
         * 获取指定范围内的文本信息
         * @param startCharIndex 起始字符索引
         * @param count 数量
         * @returns {string} 指定范围内的文本信息
         */
        this.getPageText = function (startCharIndex, count)
        {
            var totalCharCount = this.getSize();  //获取所有字符数
            if (startCharIndex < 0 || startCharIndex >= totalCharCount || count <= 0) {
                return "";
            }
            if (startCharIndex + count > totalCharCount) {
                count = totalCharCount - startCharIndex;
            }
            var startObjIndex = -1; //文本对象索引
            var objStartCharIndex = -1;  //起始字符索引
            var objCount = this.textObjectList.length; //文本对象数量
            var text = "";
            for (var i = 0; i < objCount; i++) {
                var textObj = this.textObjectList[i];
                var objLastCharIndex = textObj.objIndex + textObj.getSize() - 1;
                if (startCharIndex <= objLastCharIndex) {
                    startObjIndex = i;
                    objStartCharIndex = startCharIndex - textObj.objIndex;
                    if (objStartCharIndex < 0) {
                        objStartCharIndex = 0;
                        text = " "; //单词前加个空格
                        count--;
                    }
                    break;
                }
            }
            var nextObjIndex = startObjIndex;
            var nextObjStartCharIndex = objStartCharIndex;
            while (count > 0) {
                if (nextObjIndex >= objCount) {
                    return "";
                }
                var nextTextObj = this.textObjectList[nextObjIndex];
                var objCharCount = nextTextObj.getSize(); //当前文本对象的字符数量
                var leaveCharCount = objCharCount - nextObjStartCharIndex;
                text += nextTextObj.getCharCodeText(nextObjStartCharIndex, count);
                count = count - leaveCharCount;
                if (count > 0 && nextObjIndex != objCount - 1) {
                    var nextTextObj2 = this.textObjectList[nextObjIndex + 1];
                    var nextObj2StartCharIndex = nextTextObj2.objIndex;
                    var nextObjLastCharIndex = nextTextObj.objIndex + nextTextObj.getSize() - 1;
                    var nextLine2 = nextTextObj2.lineIndex;
                    var nextLine = nextTextObj.lineIndex;
                    if (nextLine2 != nextLine) {
                        var next_charStart = nextTextObj2.charIndex;
                        var cur_charEnd = nextTextObj.charIndex + nextTextObj.getStrSize() - 1;
                        if (next_charStart - cur_charEnd != 1) {
                            text += "\r\n";
                        }
                    }
                    else if (nextObj2StartCharIndex - nextObjLastCharIndex != 1) {
                        text += " ";
                        count--;
                    }
                }
                nextObjIndex++;
                nextObjStartCharIndex = 0;
            }
            return text;
        };


        function _getBoundPageInfo(rcBound, nfrom, nto, boundInfo) {
            if (nfrom > nto) {
                return false;
            }
            var nStart = -1;
            var nEnd = -1;
            var i, j, size ,rect;
            for (i = nfrom; i <= nto; i++) {
                rect = _self.textObjectList[i].getAllObjectPDFRect(true);
                RectUtils.intersect(rect,rcBound);
                if (!RectUtils.isEmpty(rect)) {
                    size = _self.textObjectList[i].getSize();
                    for (j = 0; j < size; j++) {
                        rect = _self.textObjectList[i].getObjectPDFRect(j, 1);
                        RectUtils.intersect(rect,rcBound);
                        if (!RectUtils.isEmpty(rect)) {
                            nStart = _self.textObjectList[i].objIndex + j;
                            break;
                        }
                    }
                }
                if (nStart != -1) {
                    break;
                }
            }
            if (nStart == -1) {
                return false;
            }
            for (i = nto; i >= nfrom; i--) {
                rect = _self.textObjectList[i].getAllObjectPDFRect(true);
                RectUtils.intersect(rect,rcBound);
                if (!RectUtils.isEmpty(rect)) {
                    size = _self.textObjectList[i].getSize();
                    for (j = size - 1; j >= 0; j--) {
                        rect = _self.textObjectList[i].getObjectPDFRect(j, 1);
                        RectUtils.intersect(rect,rcBound);
                        if (!RectUtils.isEmpty(rect)) {
                            nEnd = _self.textObjectList[i].objIndex + j;
                            break;
                        }
                    }
                }
                if (nEnd != -1) {
                    break;
                }
            }
            boundInfo.startIndex = nStart;
            boundInfo.endIndex = nEnd;
            return true;
        }

        this.getBoundPageInfo = function (rcBound, boundArray) {
            for (var i = 0; i < this.lineCount; i++) {
                var lineRangeInfo = new TextBoundInfo(-1, -2);
                this.getLineRange(i, lineRangeInfo);
                var info = new TextBoundInfo(-1, -1);
                if (_getBoundPageInfo(rcBound, lineRangeInfo.startIndex, lineRangeInfo.endIndex, info)) {
                    boundArray.push(info);
                }
            }
            return boundArray.length != 0;
        };

        function _getWordLeftPos(charIndex)
        {
	        if(charIndex<0 || charIndex>=_self.getSize())
	        {
		        return -1;
	        }
		    var csText = _self.getPageText(charIndex, 1);
	        var  size = csText.length;
	        if (size == 0 ) {
		        return charIndex;
	        }
	        var j;
	        for(j=size-1; j>=0; j--)
	        {
		        if( !_isAnsiWordOrDigital( csText.charAt(j) )  )
		        {
			        if (j == size-1){
				        return -1;
			        }
			        else  {
				        return charIndex;
			        }
		        }
	        }

            var nWordLine = _self.getLineIndexByIndex(charIndex);
            var lineRangeInfo = new TextBoundInfo(-1, -1);
            var bRet = _self.getLineRange(nWordLine, lineRangeInfo);
	        if(!bRet) {
                return -1;
            }
            var  line_stIndex = lineRangeInfo.startIndex;
            var  line_endIndex = lineRangeInfo.endIndex;
            line_stIndex = _self.textObjectList[line_stIndex].objIndex;
	        line_endIndex = _self.textObjectList[line_endIndex].objIndex + _self.textObjectList[line_endIndex].getSize() - 1;
	        var bStart = false;

	        var start_index=0;
	        for (j=charIndex-1; j>=line_stIndex; j--)
	        {
	            csText = _self.getPageText(j, 1);
		        size = csText.length;
		        //var line_index = _self.getLineIndexByIndex(j);
		        for(var i=size-1; i>=0; i--)
		        {
			        if(!_isAnsiWordOrDigital(csText.charAt(i))  )
			        {
				        if (i == size-1) {
					        start_index = j+1;
				        }
				        else{
					        start_index = j;
				        }
				        bStart = true;
				        break;
			        }
		        }
		        if (bStart) {
			        break;
		        }
	        }
	        if (!bStart) {
		        start_index =line_stIndex;
	        }

	        if (start_index != line_stIndex)
	        {
		        return start_index;
	        }
	        if (nWordLine == 0)  {
		        return start_index;
	        }

            lineRangeInfo.startIndex = -1;
            lineRangeInfo.endIndex = -1;
            bRet = _self.getLineRange(nWordLine - 1, lineRangeInfo);
            if(!bRet)
                return -1;
            line_stIndex = lineRangeInfo.startIndex;
            line_endIndex = lineRangeInfo.endIndex;
            line_endIndex = _self.textObjectList[line_endIndex].objIndex + _self.textObjectList[line_endIndex].getSize() - 1;
            csText = _self.getPageText(line_endIndex, 1);
	        size = csText.length;
	        var temp_text = _self.getPageText(start_index, 1);
	        if (temp_text.charAt(0)!= '-' && csText.charAt(size-1) != '-')
	        {
		        return start_index;
	        }
	        var temp_pos= _getWordLeftPos(line_endIndex);
	        if( temp_pos != -1)
	        {
		        start_index = temp_pos;
	        }
	        return start_index;
        }

        function _getWordRightPos(charIndex)
        {
            if (charIndex < 0 || charIndex >= _self.getSize()) {
		        return -1;
	        }
		    var csText = _self.getPageText(charIndex, 1);
	        var size = csText.length;
	        if (size == 0 )  {
		        return charIndex;
	        }
	        var j;
	        for(j=0; j<size; j++)
	        {
		        if( !_isAnsiWordOrDigital(csText.charAt(j)) )
		        {
			        if (j == 0) {
				        return -1;
			        }
			        else  {
				        return charIndex;
			        }
		        }
	        }


            var nWord_Line = _self.getLineIndexByIndex(charIndex);
            var lineRangeInfo = new TextBoundInfo(-1, -1);
            var bRet = _self.getLineRange(nWord_Line, lineRangeInfo);
	        if(!bRet) {
                return -1;
            }
            var  line_stIndex = lineRangeInfo.startIndex;
            var  line_endIndex = lineRangeInfo.endIndex;
            line_endIndex = _self.textObjectList[line_endIndex].objIndex + _self.textObjectList[line_endIndex].getSize() - 1;
	        var bEnd=false;

	        var end_index=0;
	        for (j=charIndex+1; j<=line_endIndex; j++)
	        {
	            csText = _self.getPageText(j, 1);
		        size = csText.length;
		        for(var i=0;i<size;i++)
		        {
			        if(!_isAnsiWordOrDigital(csText.charAt(i)) )//255以上是非abc字符
			        {
				        if (i == 0) {
					        end_index=j-1;
				        }
				        else {
					        end_index=j;
				        }
				        bEnd = true;
				        break;
			        }
		        }
		        if (bEnd) {
			        break;
		        }
	        }
	        if (!bEnd) {
		        end_index =line_endIndex;
	        }
	
	        if (end_index != line_endIndex)   {
		        return end_index;
	        }

		    if (nWord_Line == _self.lineCount - 1)
	        {
		        return end_index;
	        }

            lineRangeInfo.startIndex = -1;
            lineRangeInfo.endIndex = -1;
            bRet = _self.getLineRange(nWord_Line + 1, lineRangeInfo);
            if(!bRet)  {
                return -1;
            }
            line_stIndex = lineRangeInfo.startIndex;
            line_endIndex = lineRangeInfo.endIndex;
            line_stIndex = _self.textObjectList[line_stIndex].objIndex;
            line_endIndex = _self.textObjectList[line_endIndex].objIndex + _self.textObjectList[line_endIndex].getSize() - 1;
            csText = _self.getPageText(line_endIndex, 1);
	        var temp_text = _self.getPageText(end_index, 1);
	        if (temp_text.charAt(temp_text.length-1)!='-' && csText.charAt(0)!= '-')
	        {
		        return end_index;
	        }
	        var temp_pos= _getWordRightPos(line_stIndex);
	        if( temp_pos != -1)
	        {
		        end_index = temp_pos;
	        }
	        return end_index;
        }

        this.getWordRange = function(charIndex,boundInfo)
        {
	        if(charIndex<0 || charIndex>=this.getSize())   {
		        return false;
	        }

	        boundInfo.startIndex = _getWordLeftPos(charIndex);
	        if (boundInfo.startIndex == -1)
	        {
		        boundInfo.startIndex = boundInfo.endIndex = charIndex;
	        }
	        boundInfo.endIndex = _getWordRightPos(charIndex);
	        if (boundInfo.endIndex == -1)
	        {
		        boundInfo.startIndex = boundInfo.endIndex = charIndex;
	        }
	        return true;
        };

        this.getLineRange = function (lineIndex, boundInfo) {
            var index = this.binarySearch(lineIndex);
            if (index == -1) {
                return false;
            }
            boundInfo.startIndex = boundInfo.endIndex = index;
            for (var i = index - 1; i >= 0; i--) {
                if (this.textObjectList[i].lineIndex == lineIndex) {
                    boundInfo.startIndex = i;
                }
                else {
                    break;
                }
            }
            var size = this.textObjectList.length;
            for (var j = index + 1; j < size; j++) {
                if (this.textObjectList[j].lineIndex == lineIndex) {
                    boundInfo.endIndex = j;
                }
                else {
                    break;
                }
            }
            return true;
        };

        this.binarySearch = function (lineIndex) {
            //在有序表R[0..n-1]中进行二分查找，成功时返回结点的位置，失败时返回零;
            var low = 0, high = this.textObjectList.length - 1, mid; //置当前查找区间上、下界的初值;
            while (low <= high) {
                //当前查找区间R[low..high]非空
                mid = parseInt((low + high) / 2);
                if (this.textObjectList[mid].lineIndex == lineIndex) return mid; //查找成功返回;
                else if (this.textObjectList[mid].lineIndex > lineIndex)
                    high = mid - 1; //继续在R[low..mid-1]中查找;
                else
                    low = mid + 1; //继续在R[mid+1..high]中查找;
            }
            return -1; //当low>high时表示查找区间为空，查找失败;
        };

        this.getLineIndexByIndex = function (objIndex) {
            var size = this.textObjectList.length;
            for (var i = 0; i < size; i++) {
                if (objIndex <= this.textObjectList[i].objIndex + this.textObjectList[i].getSize() - 1) {
                    return this.textObjectList[i].lineIndex;

                }
            }
            return -1;
        };

        function _getObjTextIndexByItemIndex(objIndex) {
            var size = _self.textObjectList.length;
            for (var i = 0; i < size; i++) {
                if (objIndex <= _self.textObjectList[i].objIndex + _self.textObjectList[i].getSize() - 1) {
                    if (objIndex < _self.textObjectList[i].objIndex) {
                        return -1;
                    }
                    return i;
                }
            }
            return -1;
        }

        this.getCaretByIndex = function (charIndex, caretInfo, bLeft) {
            if (charIndex < 0 || charIndex >= this.getSize()) {
                return false;
            }
            var objTextIndex = _getObjTextIndexByItemIndex(charIndex);
            if (objTextIndex == -1) {
                return false;
            }
            var objCharIndex = charIndex - this.textObjectList[objTextIndex].objIndex;
            this.textObjectList[objTextIndex].getTextCaretInfoByIndex(objCharIndex, caretInfo, bLeft);
            caretInfo.index += this.textObjectList[objTextIndex].objIndex;
            return true;
        };

        this.getCaretAtPoint = function (point, caretInfo) {
            var objTextIndex = this.getObjTextIndexByPoint(point);
            if (objTextIndex == -1) {
                return false;
            }
            var bRet = this.textObjectList[objTextIndex].getTextCaretInfo(point, caretInfo);
            if (bRet) {
                caretInfo.index += this.textObjectList[objTextIndex].objIndex;
                return true;
            }
            else {
                return false;
            }
        };
    };

    return WebPDF.PDFData.Text.PDFTextPage;
});